package com.glp.work.flow.service;

import com.glp.common.reponse.BaseResult;
import com.glp.work.flow.dto.UserEntity;
import com.glp.work.flow.dto.request.PersonInfoReq;
import com.glp.work.flow.dto.request.RoleAndPermReq;
import com.glp.work.flow.dto.request.UsersRequstDto;
import com.glp.work.flow.pojo.RoleCodes;
import com.glp.work.flow.request.RoleRequest;
import com.glp.work.flow.response.RolesResponse;
import com.glp.work.flow.service.impl.PermissionClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "fbs-app", fallback = PermissionClientFallback.class)
public interface PermissionClient {

    @RequestMapping(value = "/fbs-app/user/roleAndPermList", method = RequestMethod.GET)
    BaseResult getRoleAndPermList(@RequestHeader(value = "userNo") String userNo, @RequestHeader(value = "appId") String appId);

    @RequestMapping(value = "/fbs-app/user/personInfo", method = RequestMethod.GET)
    BaseResult getPersonInfo(@RequestHeader(value = "userNo") String userNo);

    @RequestMapping(value = "/fbs-app/user/personInfos", method = RequestMethod.POST)
    BaseResult getPersonInfos(PersonInfoReq req);

    @RequestMapping(value = "/fbs-app/user/appList", method = RequestMethod.GET)
    BaseResult getAppList(@RequestHeader(value = "userNo") String userNo);

    @RequestMapping(value = "/fbs-app/user/getRoleIdsAndPermIds/{userNo}", method = RequestMethod.GET)
    BaseResult getRoleIdsAndPermIds(@PathVariable("userNo") String userNo);

    @RequestMapping(value = "/fbs-app/user/getPermIdsByRoleIds", method = RequestMethod.POST)
    BaseResult getPermIdsByRoleIds(RoleAndPermReq req);

    @RequestMapping(value = "/fbs-app/accountManage/userNoList/{roleCode}", method = RequestMethod.GET)
    BaseResult getUserNoListByRoleId(@PathVariable("roleCode") String roleCode, @RequestHeader(value = "appId") String appId);

    @RequestMapping(value = "/fbs-app/user/subPersonInfos", method = RequestMethod.GET)
    BaseResult getSubPersonInfos(@RequestParam("userNo") String userNo);

    @RequestMapping(value = "/fbs-app/loginManage/logout", method = RequestMethod.GET)
    BaseResult logout(@RequestParam("token") String token, @RequestHeader(value = "appId") String appId);


    @RequestMapping(value = "/fbs-app/appInfo/users", method = RequestMethod.POST)
    BaseResult<List<UserEntity>> userList(@RequestBody UsersRequstDto dto);

    /**
     * @MethodName: enabledRoles
     * @Description: 应用下可用用的角色列表
     * @Param: [userNo]
     * @Return: com.glp.common.reponse.BaseResult<java.util.List < com.glp.work.flow.dto.RoleDTO>>
     * @Author: ywguo
     * @Date: 2020/6/8
     **/
    @RequestMapping(value = "/fbs-app/appInfo/enabledRoles", method = RequestMethod.POST)
    BaseResult<List<RolesResponse>> enabledRoles(@RequestBody RoleRequest roleRequest);


    /**
     * @description : 获取当前登录用户所在的系统的角色信息
     * @params : [userNo, appId]
     * @returns : com.glp.common.reponse.BaseResult<java.util.List<com.glp.work.flow.response.RolesResponse>>
     * @author : 郭永伟
     * @date : 2020/9/15
     */
    @RequestMapping(value = "/fbs-app/user/personRoles", method = RequestMethod.GET)
    BaseResult personRoles(@RequestHeader(value = "userNo") String userNo, @RequestHeader(value = "appId") String appId);

    /**
     * @MethodName: personInfosByRoleCodeList
     * @Description: 根据角色得到对应的用户列表
     * @Param: [userNo, appId, roleCodes]
     * @Return: com.glp.common.reponse.BaseResult
     * @Author: ywguo
     * @Date: 2020/6/9
     **/
    @RequestMapping(value = "/fbs-app/user/personInfosByRoleCodeList", method = RequestMethod.POST)
    BaseResult personInfosByRoleCodeList(@RequestBody RoleCodes roleCodes);

    /**
     * @description :获取当前登录用户用户所有的应用角色信息
     * @params : [userNo]
     * @returns : com.glp.common.reponse.BaseResult
     * @author : 郭永伟
     * @date : 2020/9/18
     */
    @RequestMapping(value = "/fbs-app/user/getPersonAllEnableRoles", method = RequestMethod.GET)
    BaseResult getPersonAllEnableRoles(@RequestHeader(value = "userNo") String userNo);

    /**
     * @description : 根据appId和userNO查询用户信息
     * @params : [createUserId, appId]
     * @returns : com.glp.common.reponse.BaseResult
     * @author : 郭永伟
     * @date : 2020/9/24
     */
    @RequestMapping(value = "/fbs-app/user/personInfo", method = RequestMethod.GET)
    BaseResult getPersonInfo(@RequestHeader(value = "userNo") String createUserId, @RequestHeader(value = "appId") String appId);

    /**
     * @description : 获取用户直属下级
     * @params : [userNo]
     * @returns : com.glp.common.reponse.BaseResult
     * @author : 郭永伟
     * @date : 2020/10/21
     */
    @RequestMapping(value = "/fbs-app/user/getPersonSubordinate", method = RequestMethod.GET)
    BaseResult getPersonSubordinate(@RequestHeader(value = "userNo") String userNo);

    @RequestMapping(value = "/fbs-app/user/personInfos", method = RequestMethod.POST)
    BaseResult getPersonInfos(@RequestHeader(value = "appId") String appId, PersonInfoReq req);
}

